package com.SmartWallet;

import com.SmartWallet.models.ListEntry;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class NewEntryActivity extends Activity{
	String name, type, comment;
	int cost;
	public void onCreate(Bundle savedInstanceState) {
		  super.onCreate(savedInstanceState);
		  this.setContentView(R.layout.entrylayout);
		  final Button button = (Button) findViewById(R.id.add_button);
		  final EditText nameBox = (EditText) findViewById(R.id.namebox);
		  final EditText typeBox = (EditText) findViewById(R.id.type);
		  final EditText costBox = (EditText) findViewById(R.id.cost);
		  final EditText commentBox = (EditText) findViewById(R.id.comment);
		  
	         button.setOnClickListener(new View.OnClickListener() {
	             public void onClick(View v) {
	                 // Perform action on click
	            	 name = nameBox.getText().toString();
	            	 type = typeBox.getText().toString();
	            	 cost = Integer.parseInt(costBox.getText().toString());
	            	 comment = commentBox.getText().toString();
	            	 
	            	 SmartWalletActivity.lists.get(SmartWalletActivity.selected).addEntry(new ListEntry(name,cost,comment,type));
	            	/* Intent intent = new Intent(NewEntryActivity.this,ListViewActivity2.class);			
	 				

	 				

	 				//Start next activity
	 				NewEntryActivity.this.startActivity(intent); */
	            	 Intent intent = new Intent();
	                 setResult(RESULT_OK, intent);
	                 finish();
	            	 
	            	 
	             }
	         });
		  
		 
		  
	}
	
	@Override
    protected void onStart() {
        super.onStart();
        // The activity is about to become visible.
    }
    @Override
    protected void onResume() {
        super.onResume();
        // The activity has become visible (it is now "resumed").
    }
    @Override
    protected void onPause() {
        super.onPause();
        // Another activity is taking focus (this activity is about to be "paused").
    }
    @Override
    protected void onStop() {
        super.onStop();
        // The activity is no longer visible (it is now "stopped")
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        // The activity is about to be destroyed.
    }

}
